home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / sdi / text.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-18  |  4.4 KB  |  193 lines

  1. /*****************************  text.c  ******************************/
  2. #include "sdi.h"
  3. #define PIES
  4. #ifdef PIES
  5. #include "piemenu.h"
  6. #endif
  7.  
  8. /*
  9.  * Copyright 1987 by Mark Weiser.
  10.  * Permission to reproduce and use in any manner whatsoever on Suns is granted
  11.  * so long as this copyright and other identifying marks of authorship
  12.  * in the code and the game remain intact and visible.  Use of this code
  13.  * in other products is reserved to me--I'm working on Mac and IBM versions.
  14.  */
  15.  
  16. /*
  17.  * Find the size of the longest line in a string of lines separated by newlines
  18.  */
  19. max_line(s)
  20. char *s;
  21. {
  22.     int max = 0, count = 0;
  23.     while (*s) {
  24.         if (*s++ == '\n') {
  25.             if (count > max)
  26.                 max = count;
  27.             count = 0;
  28.             continue;
  29.         }
  30.         count += 1;
  31.     }
  32.     if (count > max)
  33.         max = count;
  34.     return max;
  35. }
  36.  
  37. /*
  38.  * Count the number of lines in a string of lines separated by newlines.
  39.  */
  40. count_lines(s)
  41. char *s;
  42. {
  43.     int count = 0;
  44.     while (*s) {
  45.         if (*s++ == '\n')
  46.             count += 1;
  47.     }
  48.     return count+1;
  49. }
  50.  
  51. static char *help_msg[] = {
  52. #include "novice_advice.h"
  53.     ,
  54. #include "occasional_advice.h"
  55.     ,
  56. #include "expert_advice.h"
  57.     };
  58.  
  59. /*
  60.  * Display a brief message of advice appropriate to the current skill level.
  61.  */
  62. void
  63. help_proc(item, event)
  64. Panel_item item;
  65. Event *event;
  66. {
  67.     int skill = (int)panel_get_value(skill_item);
  68.     popup_msg(controlframe, event, help_msg[skill]);
  69. }
  70.  
  71. static char *about_msg = 
  72. #include "about_msg.h"
  73.     ;
  74. /*
  75.  * Display a brief informative message about the game.
  76.  */
  77. void
  78. about_proc(item, event)
  79. Panel_item item;
  80. Event *event;
  81. {
  82.     popup_msg(controlframe, event, about_msg);
  83. }
  84.  
  85. static char *art_msg = "This space reserved for Marcel Duchamp";
  86. /*
  87.  * Display a brief informative message about art.
  88.  */
  89. void
  90. art_proc(item, event)
  91. Panel_item item;
  92. Event *event;
  93. {
  94.     popup_msg(controlframe, event, art_msg);
  95. }
  96.  
  97. /*
  98.  * Display the complete source code of the game in a popup window.
  99.  * The external variable 'source code' must be properly filled elsewhere.
  100.  * (See the sdi makefile for one way.)
  101.  */
  102. void
  103. source_proc(item, event)
  104. Panel_item item;
  105. Event *event;
  106. {
  107.     extern char *source_code;
  108.     popup_msg(controlframe, event, source_code);
  109. }
  110.  
  111. /*
  112.  * Display the history of the game's development in a popup window.
  113.  * The external variable 'history_text' must be properly filled elsewhere.
  114.  * (See the sdi makefile for one way.)
  115.  */
  116. void
  117. history_proc(item, event)
  118. Panel_item item;
  119. Event *event;
  120. {
  121.     extern char *history_text;
  122.     popup_msg(controlframe, event, history_text);
  123. }
  124.  
  125. /*
  126.  * Display the man entry in a popup (sort of) window.
  127.  * The external variable 'man_text' must be properly filled elsewhere.
  128.  * (See the sdi makefile for one way.)
  129.  */
  130. void
  131. man_proc(item, event)
  132. Panel_item item;
  133. Event *event;
  134. {
  135.     extern char *man_text;
  136.     popup_msg(controlframe, event, man_text);
  137. }
  138.  
  139. void
  140. instructions_proc()
  141. {
  142.     easy_pop(
  143. #include "instructions.h"
  144.         );
  145. }
  146.  
  147. void
  148. version_proc()
  149. {
  150.     extern char *version;
  151.     easy_pop(version);
  152.  
  153. }
  154.  
  155. text_options_proc(item, event)
  156. Panel_item item;
  157. Event *event;
  158. {
  159.     extern scores_proc();
  160.     extern struct pixfont *buttonfont; /* use 'struct pixfont' for 3.0 compatiblity */
  161.     Menu_item mi;
  162.     Menu menu, menu_create();
  163.     int (*selection)();
  164.     suspend_proc();
  165.     menu = menu_create(MENU_NOTIFY_PROC, menu_return_item, 0);
  166.     menu_set(menu, MENU_APPEND_ITEM, menu_create_item(MENU_STRING, "Source", MENU_CLIENT_DATA, source_proc, 0), 0);
  167.     menu_set(menu, MENU_APPEND_ITEM, menu_create_item(MENU_STRING, "History", MENU_CLIENT_DATA, history_proc, 0), 0);
  168.     menu_set(menu, MENU_APPEND_ITEM, menu_create_item(MENU_STRING, "Man", MENU_CLIENT_DATA, man_proc, 0), 0);
  169.     menu_set(menu, MENU_APPEND_ITEM, menu_create_item(MENU_STRING, "Scores", MENU_CLIENT_DATA, scores_proc, 0), 0);
  170.     menu_set(menu, MENU_APPEND_ITEM, menu_create_item(MENU_STRING, "About", MENU_CLIENT_DATA, about_proc, 0), 0);
  171.     menu_set(menu, MENU_APPEND_ITEM, menu_create_item(MENU_STRING, "Art", MENU_CLIENT_DATA, art_proc, 0), 0);
  172.     menu_set(menu, MENU_APPEND_ITEM, menu_create_item(MENU_STRING, "Advice", MENU_CLIENT_DATA, help_proc, 0), 0);
  173.     menu_set(menu, MENU_APPEND_ITEM, menu_create_item(MENU_STRING, "Version", MENU_CLIENT_DATA, version_proc, 0), 0);
  174.     special_menu_show(menu, event);
  175. }
  176.  
  177. special_menu_show(menu, event)
  178. {
  179.     int notify_me();
  180.     pie_menu_show(menu, controlframe, event, notify_me, "Things To Read ('pie' form)");
  181. }
  182.  
  183. notify_me(mi, event)
  184. Menu_item mi;
  185. {
  186.     int (*selection)();
  187.     if (mi != NULL){
  188.         (caddr_t)selection = (caddr_t)menu_item_get(mi, MENU_CLIENT_DATA);
  189.         (*selection)(0, event);
  190.     }
  191.     resume_proc();
  192. }
  193.